home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / terminal / top_152 / src152.exe / rar / TOPV24.PAS < prev    next >
Pascal/Delphi Source File  |  1995-05-16  |  18KB  |  711 lines

  1. {┌─────────────────────────────────────────────────────────────────────────┐}
  2. {│                                                                         │}
  3. {│                              T. O. P.                                   │}
  4. {│                                                                         │}
  5. {│                        (T)he  (O)ther  (P)acket                         │}
  6. {│                                                                         │}
  7. {│ T O P V 2 4 . P A S                                                     │}
  8. {│                                                                         │}
  9. {│                                                                         │}
  10. {│ - Routinen zur Bedienung bis zu 4 Schnittstellen +                      │}
  11. {│   Hardware-Umschaltung bei Multiplexkarten.                             │}
  12. {│                                                                         │}
  13. {│ - Interface zum TFPCR-, TFPCX-Treiber von DL1MEN bzw. DG0FT             │}
  14. {│   Es wird nach dem passenden Software-Interrupt im Bereich              │}
  15. {│   $40 bis $FF gesucht!                                                  │}
  16. {└─────────────────────────────────────────────────────────────────────────┘}
  17.  
  18. Function  IntFlag : Boolean;
  19. Var   FlagInt : Word;
  20. Begin
  21.   asm
  22.       pushf
  23.       pop   ax
  24.       mov   FlagInt, ax
  25.   end;
  26.   IntFlag := (FlagInt and $200) = $200;
  27. End;
  28.  
  29.  
  30. Procedure RTS_Setzen (Nr : Byte);
  31. Begin
  32.   Port[COM[Nr].Base+$04] := (Port[COM[Nr].Base+$04] or $02);
  33. End;
  34.  
  35. Procedure RTS_Loeschen (Nr : Byte);
  36. Begin
  37.   Port[COM[Nr].Base+$04] := (Port[COM[Nr].Base+$04] and (FF-$02));
  38. End;
  39.  
  40.  
  41. Procedure IRQsLock;
  42. Begin
  43.   if IrqMask > 0 then Port[$21] := Port[$21] or IrqMask;
  44.   SynchError := false;
  45.   OverRun := false;
  46. End;
  47.  
  48. Procedure IRQsFree;
  49. Begin
  50.   if IrqMask > 0 then Port[$21] := Port[$21] and (FF - IrqMask);
  51. End;
  52.  
  53.  
  54. Procedure get_Chr_TFPC;
  55. Var  r : Registers;
  56.      b : Byte;
  57. Begin
  58.   if TFPC_installed then
  59.   begin
  60.     r.AH := $01;
  61.     Intr(Kiss_Int,r);
  62.     if r.AX = 1 then
  63.     begin
  64.       r.AH := $02;
  65.       Intr(Kiss_Int,r);
  66.       b := r.AL;
  67.       V24Buffer[BufferPos] := b;
  68.       inc(BufferPos);
  69.       if BufferPos >= maxComBuf then ClearV24Buffer;
  70.     end;
  71.   end;
  72.  
  73.   if DRSI_installed then
  74.   begin
  75.     r.AH := $00;
  76.     Intr(Kiss_Int,r);
  77.     if r.AH = 1 then
  78.     begin
  79.       b := r.AL;
  80.       V24Buffer[BufferPos] := b;
  81.       inc(BufferPos);
  82.       if BufferPos >= maxComBuf then ClearV24Buffer;
  83.     end;
  84.   end;
  85. End;
  86.  
  87.  
  88. {
  89. Procedure get_Chr_Hs (* V24Nr : Byte *);
  90. Begin
  91.   Repeat
  92.     CB := Port[COM[V24Nr].Base + $05];
  93.     TRead := CB and $01 = $01;
  94.     if TRead then
  95.     begin
  96.       V24Buffer[BufferPos] := Port[COM[V24Nr].Base];
  97.       inc(BufferPos);
  98.       if BufferPos >= maxComBuf then ClearV24Buffer;
  99.     end;
  100.     if CB and $02 = $02 then OverRun := true;
  101.   Until not TRead;
  102. End;
  103. }
  104.  
  105. Procedure get_Chr_Hs (* V24Nr : Byte *); Assembler;
  106. Asm
  107.   @1:
  108.      xor  ax, ax
  109.      mov  al, V24Nr
  110.      dec  al
  111.      shl  al, $01
  112.      mov  bx, Offset Default_Base
  113.      add  bx, ax
  114.      mov  dx, [ds:bx]
  115.      add  dx, $05
  116.  
  117.      in   al, dx
  118.      test al, $02
  119.      jz   @2
  120.      mov  OverRun, $01
  121.   @2:
  122.      test al, $01
  123.      jz   @4
  124.  
  125.      sub  dx, $05
  126.      in   al, dx
  127.  
  128.      mov  si, BufferPos
  129.      mov  bx, Offset V24Buffer
  130.      mov  [ds:bx+si], al
  131.      inc  BufferPos
  132.      cmp  BufferPos, maxComBuf
  133.      jb   @3
  134.      mov  BufferPos, $00
  135.   @3:
  136.      jmp  @1
  137.   @4:
  138. End;
  139.  
  140. (*
  141. {$F+} Procedure Com_Int1; {$F-}  Interrupt;
  142. Const  V24Nr = 1;
  143. Begin
  144.   Repeat
  145.     CB := Port[COM[V24Nr].Base + $05];
  146.     TRead := CB and $01 = $01;
  147.     if TRead then
  148.     begin
  149.       V24Buffer[BufferPos] := Port[COM[V24Nr].Base];
  150.       inc(BufferPos);
  151.       if BufferPos >= maxComBuf then ClearV24Buffer;
  152.     end;
  153.     if CB and $02 = $02 then OverRun := true;
  154.   Until not TRead;
  155.  
  156.   if COM[V24Nr].IRQ_Nr > 7 then Port[$A0] := $20;
  157.   Port[$20] := $20;
  158. End;
  159.  
  160. {$F+} Procedure Com_Int2; {$F-}  Interrupt;
  161. Const  V24Nr = 2;
  162. Begin
  163.   Repeat
  164.     CB := Port[COM[V24Nr].Base + $05];
  165.     TRead := CB and $01 = $01;
  166.     if TRead then
  167.     begin
  168.       V24Buffer[BufferPos] := Port[COM[V24Nr].Base];
  169.       inc(BufferPos);
  170.       if BufferPos >= maxComBuf then ClearV24Buffer;
  171.     end;
  172.     if CB and $02 = $02 then OverRun := true;
  173.   Until not TRead;
  174.  
  175.   if COM[V24Nr].IRQ_Nr > 7 then Port[$A0] := $20;
  176.   Port[$20] := $20;
  177. End;
  178.  
  179. {$F+} Procedure Com_Int3; {$F-}  Interrupt;
  180. Const  V24Nr = 3;
  181. Begin
  182.   Repeat
  183.     CB := Port[COM[V24Nr].Base + $05];
  184.     TRead := CB and $01 = $01;
  185.     if TRead then
  186.     begin
  187.       V24Buffer[BufferPos] := Port[COM[V24Nr].Base];
  188.       inc(BufferPos);
  189.       if BufferPos >= maxComBuf then ClearV24Buffer;
  190.     end;
  191.     if CB and $02 = $02 then OverRun := true;
  192.   Until not TRead;
  193.  
  194.   if COM[V24Nr].IRQ_Nr > 7 then Port[$A0] := $20;
  195.   Port[$20] := $20;
  196. End;
  197.  
  198. {$F+} Procedure Com_Int4; {$F-}  Interrupt;
  199. Const  V24Nr = 4;
  200. Begin
  201.   Repeat
  202.     CB := Port[COM[V24Nr].Base + $05];
  203.     TRead := CB and $01 = $01;
  204.     if TRead then
  205.     begin
  206.       V24Buffer[BufferPos] := Port[COM[V24Nr].Base];
  207.       inc(BufferPos);
  208.       if BufferPos >= maxComBuf then ClearV24Buffer;
  209.     end;
  210.     if CB and $02 = $02 then OverRun := true;
  211.   Until not TRead;
  212.  
  213.   if COM[V24Nr].IRQ_Nr > 7 then Port[$A0] := $20;
  214.   Port[$20] := $20;
  215. End;
  216. *)
  217.  
  218. {$F+} Procedure Com_Int1; {$F-}  Interrupt;  Assembler;
  219. Asm
  220.   @1:
  221.      mov  dx, ComAdr1
  222.      add  dx, $05
  223.      in   al, dx
  224.      test al, $02
  225.      jz   @2
  226.      mov  OverRun, $01
  227.   @2:
  228.      test al, $01
  229.      jz   @4
  230.  
  231.      sub  dx, $05
  232.      in   al, dx
  233.  
  234.      mov  si, BufferPos
  235.      mov  bx, Offset V24Buffer
  236.      mov  [ds:bx+si], al
  237.      inc  BufferPos
  238.      cmp  BufferPos, maxComBuf
  239.      jb   @3
  240.      mov  BufferPos, $00
  241.   @3:
  242.      jmp  @1
  243.   @4:
  244.      mov  al, $20
  245.      mov  ah, EoiPic1
  246.      test ah, $01
  247.      jz   @5
  248.      out  $A0, al
  249.  @5:
  250.      out  $20, al
  251. End;
  252.  
  253.  
  254. {$F+} Procedure Com_Int2; {$F-}  Interrupt;  Assembler;
  255. Asm
  256.   @1:
  257.      mov  dx, ComAdr2
  258.      add  dx, $05
  259.      in   al, dx
  260.      test al, $02
  261.      jz   @2
  262.      mov  OverRun, $01
  263.   @2:
  264.      test al, $01
  265.      jz   @4
  266.  
  267.      sub  dx, $05
  268.      in   al, dx
  269.  
  270.      mov  si, BufferPos
  271.      mov  bx, Offset V24Buffer
  272.      mov  [ds:bx+si], al
  273.      inc  BufferPos
  274.      cmp  BufferPos, maxComBuf
  275.      jb   @3
  276.      mov  BufferPos, $00
  277.   @3:
  278.      jmp  @1
  279.   @4:
  280.      mov  al, $20
  281.      mov  ah, EoiPic2
  282.      test ah, $01
  283.      jz   @5
  284.      out  $A0, al
  285.  @5:
  286.      out  $20, al
  287. End;
  288.  
  289.  
  290. {$F+} Procedure Com_Int3; {$F-}  Interrupt;  Assembler;
  291. Asm
  292.   @1:
  293.      mov  dx, ComAdr3
  294.      add  dx, $05
  295.      in   al, dx
  296.      test al, $02
  297.      jz   @2
  298.      mov  OverRun, $01
  299.   @2:
  300.      test al, $01
  301.      jz   @4
  302.  
  303.      sub  dx, $05
  304.      in   al, dx
  305.  
  306.      mov  si, BufferPos
  307.      mov  bx, Offset V24Buffer
  308.      mov  [ds:bx+si], al
  309.      inc  BufferPos
  310.      cmp  BufferPos, maxComBuf
  311.      jb   @3
  312.      mov  BufferPos, $00
  313.   @3:
  314.      jmp  @1
  315.   @4:
  316.      mov  al, $20
  317.      mov  ah, EoiPic3
  318.      test ah, $01
  319.      jz   @5
  320.      out  $A0, al
  321.  @5:
  322.      out  $20, al
  323. End;
  324.  
  325.  
  326. {$F+} Procedure Com_Int4; {$F-}  Interrupt;  Assembler;
  327. Asm
  328.   @1:
  329.      mov  dx, ComAdr4
  330.      add  dx, $05
  331.      in   al, dx
  332.      test al, $02
  333.      jz   @2
  334.      mov  OverRun, $01
  335.   @2:
  336.      test al, $01
  337.      jz   @4
  338.  
  339.      sub  dx, $05
  340.      in   al, dx
  341.  
  342.      mov  si, BufferPos
  343.      mov  bx, Offset V24Buffer
  344.      mov  [ds:bx+si], al
  345.      inc  BufferPos
  346.      cmp  BufferPos, maxComBuf
  347.      jb   @3
  348.      mov  BufferPos, $00
  349.   @3:
  350.      jmp  @1
  351.   @4:
  352.      mov  al, $20
  353.      mov  ah, EoiPic4
  354.      test ah, $01
  355.      jz   @5
  356.      out  $A0, al
  357.  @5:
  358.      out  $20, al
  359. End;
  360.  
  361.  
  362. {----------------------------------------------------------------------------
  363. |  Eine der V24-Schnittstellen initialisieren
  364. +----------------------------------------------------------------------------}
  365. Procedure V24_Init;
  366. Var   i,Nr,INr,dB : Byte;
  367.       w           : Word;
  368.       V24Install  : Boolean;
  369. Begin
  370.   for i := 1 to TNC_Anzahl do
  371.   begin
  372.     Nr := TNC[i]^.RS232;
  373.  
  374.     if (Nr < 5) and not COM[Nr].Active then with COM[Nr] do
  375.     begin
  376.       V24Install := (Port[Base + $05] and $60) = $60;
  377.  
  378.       if V24Install then
  379.       begin
  380.         w := 0;
  381.         While ((Port[Base + $05] and $01) = $01) and (w < EINT) do
  382.         begin
  383.           inc(w);
  384.           dB := Port[Base];
  385.         end;
  386.         if w >= EINT then V24Install := false;
  387.       end;
  388.  
  389.       if V24Install then
  390.       begin
  391.         Port[Base + $02] := FifoCfg;
  392.         FifoOn := Port[Base + $02] and $C0 = $C0;
  393.  
  394.         OrgLCR := Port[Base + $03];                { altes LCR sichern     }
  395.         OrgMCR := Port[Base + $04];                { altes MCR sichern     }
  396.         OrgIER := Port[Base + $01];                { altes IER sichern     }
  397.         Port[Base + $03] := Port[Base + $03] or $80;   { LCR : DLAB=1          }
  398.         OrgLODIV := Port[Base + $00];              { alte Baudrate sichern }
  399.         OrgHIDIV := Port[Base + $01];
  400.         Port[Base+3] := OrgLCR;
  401.  
  402.         Inline($FA);
  403.         if not HwHs then
  404.         begin
  405.           if IRQ_Nr > 7 then INr := IRQ_Nr + 104
  406.                         else INr := IRQ_Nr + 8;
  407.  
  408.           GetIntVec(INr,Old_Vector);
  409.  
  410.           Case Nr of
  411.             1 : SetIntVec(INr,@Com_Int1);
  412.             2 : SetIntVec(INr,@Com_Int2);
  413.             3 : SetIntVec(INr,@Com_Int3);
  414.             4 : SetIntVec(INr,@Com_Int4);
  415.           end;
  416.  
  417.           if IRQ_Nr > 7 then
  418.           begin
  419.             Port[$A1] := Port[$A1] and (FF - (1 shl (IRQ_Nr-8)));
  420.             Port[$21] := Port[$21] and (FF - $04);
  421.             Port[$20] := $C1;
  422.           end else
  423.           begin
  424.             Port[$21] := Port[$21] and (FF - (1 shl IRQ_Nr));
  425.             Port[$20] := $C2;        { V24 IRQ-Prioritaet setzen   }
  426.           end;
  427.         end;
  428.         Inline($FB);
  429.  
  430.         dB := Byte(Round(115200 / BaudRate));
  431.         Port[Base + $03] := Port[Base + $03] or $80; { LCR : DLAB=1                    }
  432.         Port[Base + $00] := Lo(dB);              { $06 = 19200 bd, $0C = 9600      }
  433.         Port[Base + $01] := Hi(dB);              { HI Baud                         }
  434.         Port[Base + $03] := $03;                 { LCR NoParity 8Data 1Stop:DLAB=0 }
  435.  
  436.         if not HwHs then
  437.         begin
  438.           Port[Base + $04] := $0B;               { MCR IRQ-, RTS-, DTR-Ltg freiset.}
  439.           Port[Base + $01] := $01;               { Interrupt bei Empfangsdaten     }
  440.           Verzoegern(200);
  441.         end else Port[Base + $04] := $03;        { MCR RTS und DTR= H              }
  442.  
  443.         Active := true;
  444.       end else Abbruch_TOP(13,int_str(Nr));
  445.     end;
  446.     ClearV24Buffer;
  447.   end;
  448. End;
  449.  
  450. {-----------------------------------------------------------------------------
  451. |  V24_Close  setzt alle Vektoren wieder zurück
  452. |  Neu: Interrupts werden gesperrt (nach DL4NO) 11/1989
  453. +----------------------------------------------------------------------------}
  454. Procedure V24_Close;
  455. Var    INr, i : Byte;
  456. Begin
  457.   for i := 1 to 4 do with COM[i] do
  458.   if Active then
  459.   begin
  460.     Port[Base + $01] := $00;               { serielles Port-IER sperren }
  461.     Port[Base + $04] := $00;               { IRQ-Leitung in Tristate    }
  462.  
  463.     Inline($FA);
  464.  
  465.     if not HwHs then
  466.     begin
  467.       if IRQ_Nr > 7 then INr := IRQ_Nr + 104
  468.                     else INr := IRQ_Nr + 8;
  469.       SetIntVec(INr,Old_Vector);
  470.     end;
  471.  
  472.     Port[Base + $03] := Port[Base + $03] or $80;
  473.     Port[Base + $00] := OrgLODIV;        { alte Baudrate restaurieren }
  474.     Port[Base + $01] := OrgHIDIV;
  475.     Port[Base + $03] := OrgLCR;          { LCR restaurieren           }
  476.     Port[Base + $01] := OrgIER;             { IER restaurieren           }
  477.  
  478.     Inline($FB);
  479.  
  480.     Port[Base + $04] := OrgMCR;          { MCR restaurieren           }
  481.     Active := false;
  482.   end;
  483. End;
  484.  
  485.  
  486. Procedure WriteAux (* V24Nr : Byte; Zeile : String *);
  487. Var   i : Byte;
  488.       r : Registers;
  489. Begin
  490.   if (V24Nr = 5) then
  491.   begin
  492.     for i := 1 to ord(Zeile[0]) do
  493.     begin
  494.       if TFPC_installed then r.AH := 3;
  495.       if DRSI_installed then r.AH := 1;
  496.       r.AL := Ord(Zeile[i]);
  497.       Intr(Kiss_Int,r);
  498.     end;
  499.   end else with COM[V24Nr] do
  500.   begin
  501.     for i := 1 to ord(Zeile[0]) do
  502.     begin
  503.       Repeat Until (Port[Base + $05] and 32) = 32;
  504.       Port[Base] := Ord(Zeile[i]);
  505.     end;
  506.   end;
  507. End;
  508.  
  509.  
  510. {------------------------------------------------------------------------------
  511. |  Den gewünschten TNC einschalten
  512. +-----------------------------------------------------------------------------}
  513. Procedure Switch_TNC (* TNr : Byte *);
  514. Var    sw  : Byte;
  515.        MCR : Byte;
  516. Begin
  517.   if (TNC[TNr]^.RS232 < 5) and (Old_Active_TNC <> TNr) then
  518.   begin
  519.     Old_Active_TNC := TNr;
  520.     sw := TNC[TNr]^.MPX;
  521.     if sw in [1..4] then with COM[TNC[TNr]^.RS232] do
  522.     begin
  523.       MCR := Port[Base + $04];
  524.       if HwHs then MCR := MCR and $FE
  525.               else MCR := MCR and $FC;
  526.       case sw of                            { RTS DTR }
  527.         1 : Port[Base + $04] := MCR or $00; {  L   L  } { L = ca.-12V }
  528.         2 : Port[Base + $04] := MCR or $01; {  L   H  } { H = ca.+12V }
  529.         3 : Port[Base + $04] := MCR or $02; {  H   L  }
  530.         4 : Port[Base + $04] := MCR or $03; {  H   H  }
  531.       end;
  532.       Verzoegern(2);       { ... für alle Fälle ... }
  533.     end;
  534.   end;
  535. End;
  536.  
  537.  
  538. Function ReSync (* V24Nr : Byte) : Boolean *);
  539. Var     i      : Word;
  540.         KC     : SonderTaste;
  541.         VC     : Char;
  542.         Flag   : Boolean;
  543.         Hstr   : String[10];
  544.  
  545. Begin
  546.   Inc(Resync_Z);
  547.   if Klingel then Beep(1500,20);
  548.   i := 0;
  549.   VC := #0;
  550.   Flag := false;
  551.  
  552.   Repeat
  553.     inc(i);
  554.     StatusOut(show,1,3,Attrib[14],'COM-' + int_str(V24Nr) + ' Resynch: ' + int_str(i));
  555.  
  556.     ClearV24Buffer;
  557.     WriteAux(V24Nr,#1);
  558.     Wait_Read(V24Nr);
  559.  
  560.     move(V24Buffer[2],Hstr[1],10);
  561.     Hstr[0] := #10;
  562.     Flag := pos('INVALID',Hstr) = 1;
  563.  
  564.     While _KeyPressed do _ReadKey(KC,VC);
  565.   Until (i = 260) or (VC = ^C) or Flag;
  566.  
  567.   if Flag and (VC <> ^C) then
  568.   begin
  569.     Wait_Read(V24Nr);
  570.     ClearV24Buffer;
  571.     ReSync := true;
  572.   end else ReSync := false;
  573.  
  574.   SetzeFlags(show);
  575. End;
  576.  
  577.  
  578. Procedure Wait_Read (* V24Nr : Byte *);
  579. Var  l : LongInt;
  580. Begin
  581.   TimeOut := 0;
  582.   l := TimerTick;
  583.  
  584.   if (V24Nr = 5) then
  585.   begin
  586.     Repeat
  587.       get_Chr_TFPC;
  588.       if l <> TimerTick then
  589.       begin
  590.         inc(TimeOut);
  591.         l := TimerTick;
  592.       end;
  593.     Until TimeOut >= Wait_TimeOut;
  594.   end else if HwHs then
  595.   begin
  596.     RTS_Setzen(V24Nr);
  597.     Repeat
  598.       if l <> TimerTick then
  599.       begin
  600.         inc(TimeOut);
  601.         l := TimerTick;
  602.       end;
  603.       get_Chr_Hs(V24Nr);
  604.     Until TimeOut >= Wait_TimeOut;
  605.     RTS_Loeschen(V24Nr);
  606.   end else Verzoegern(120);
  607. End;
  608.  
  609.  
  610. Procedure ClearV24Buffer;
  611. var    ch : Char;
  612. Begin
  613.   FillChar(V24Buffer,SizeOf(V24Buffer),0);
  614.   BufferPos := 0;
  615. End;
  616.  
  617.  
  618. Procedure get_Response (* Kanal *);
  619. Var     V24Nr,
  620.         a,b     : Byte;
  621.         l       : LongInt;
  622.         Ok      : Boolean;
  623. Begin
  624.   with K[Kanal]^ do
  625.   begin
  626.     V24Nr := V24(Kanal);
  627.     Ok := false;
  628.     TimeOut := 0;
  629.     l := TimerTick;
  630.     if HwHs then RTS_Setzen(V24Nr);
  631.     Repeat
  632.       if HwHs then get_Chr_Hs(V24Nr);
  633.       if V24Nr = 5 then get_Chr_TFPC;
  634.       if (BufferPos = 2) and (V24Buffer[1] = 0) then Ok := true;
  635.       if (BufferPos > 2) then
  636.       begin
  637.         if (V24Buffer[1] < 6) and (V24Buffer[BufferPos-1] = 0) then Ok := true;
  638.         if (V24Buffer[1] > 5) and (V24Buffer[2] + 4 = BufferPos) then Ok := true;
  639.       end;
  640.  
  641.       if l <> TimerTick then
  642.       begin
  643.         inc(TimeOut);
  644.         l := TimerTick;
  645.       end;
  646.     Until Ok or OverRun or (TimeOut > TNC_TimeOut);
  647.  
  648.     if HwHs then RTS_Loeschen(V24Nr);
  649.  
  650.     IRQsFree;
  651.     if OverRun then Wait_Read(V24Nr);
  652.  
  653.     if TimeOut > TNC_TimeOut then
  654.     begin
  655.       if not ReSync(V24Nr) then DRSI_Hostmode(TncNummer,1);
  656.     end else BufToResp(Kanal);
  657.  
  658.     ClearV24Buffer;
  659.   end;
  660. End;
  661.  
  662. Procedure BufToResp (* Kanal : Byte *);
  663. Var    V24Nr : Byte;
  664.        ic    : Word;
  665.        Hstr  : String[80];
  666. Begin
  667.   with K[Kanal]^ do
  668.   begin
  669.     V24Nr := V24(Kanal);
  670.  
  671.     if not (SynchError or OverRun) then
  672.     begin
  673.       Kan_Char := Chr(V24Buffer[0]);
  674.       TNC_Code := V24Buffer[1];
  675.       if (Pseudo or (Kan_Char = TNCKanal)) and ((TNC_Code >= 0) and (TNC_Code < 8)) then
  676.       begin
  677.         if (TNC_Code = 6) or (TNC_Code = 7) then
  678.         begin
  679.           TNC_Count := V24Buffer[2] + 1;
  680.           if TNC_Count > FF then ic := FF
  681.                             else ic := TNC_Count;
  682.           move(V24Buffer[3],Response[1],ic);
  683.           Response[0] := Chr(ic);
  684.           if TNC_Count > FF then Response256 := Chr(V24Buffer[TNC_Count + 2]);
  685.         end else if TNC_Code > 0 then
  686.         begin
  687.           move(V24Buffer[2],Response[1],BufferPos - 3);
  688.           Response[0] := Chr(BufferPos - 3);
  689.         end;
  690.       end else SynchError := true;
  691.     end;
  692.  
  693.     ClearV24Buffer;
  694.  
  695.     if SynchError or OverRun then
  696.     begin
  697.       inc(SynchErrAnz);
  698.       Hstr := Star + TNC[TncNummer]^.Ident + B1 + SynchErrStr + int_str(V24Nr) +
  699.               B1 + LRK + 'Chan:' + int_str(Kanal) + RRK +
  700.               B1 + LRK + 'Code:' + int_str(TNC_Code) + RRK +
  701.               B1 + LRK + 'Anz:' + int_str(SynchErrAnz) + RRK;
  702.       if OverRun then Hstr := Hstr + B1 + OverRunStr;
  703.       if not K[0]^.RxLRet then Hstr := ^J + Hstr;
  704.       M_aus(Attrib[28],Hstr + ^J);
  705.       Beep(1300,10);
  706.     end;
  707.  
  708.     Pseudo := false;
  709.   end;
  710. End;
  711.